package tyk;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class Main
{
    /*
    * 3种方式加载application.xml文件，获得该文件中管理的Bean对象
    * */
    public static void main( String[] args )
    {
        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml"); //加载核心容器
        HelloWorld helloWorld1 = (HelloWorld) context.getBean("helloWorld"); //通过id取
        HelloWorld helloWorld2 =  context.getBean(HelloWorld.class); //通过类型取
        HelloWorld helloWorld3 = (HelloWorld) context.getBean("helloWorld",HelloWorld.class); //通过id+类型取
        helloWorld1.say();
        helloWorld2.say();
        helloWorld3.say();
    }
}
